package Cinema.CinemaEntities;

/**
 * Describe a location in (x,y) coordinate system.
 * @author The Fuchtzeinsoft Team.
 *
 */
public class Location {
	
	//x coordinate
	private int x;
	public int getX(){
		return x;
	}

	//y coordinate
	private int y;
	public int getY(){
		return y;
	}

	/**
	 * Construct a new Location instance according too two coordinates.
	 * @param X  - x coordinate.
	 * @param Y  - y coordinate.
	 */
	public Location(int X, int Y ){
		x=X;
		y=Y;
	}

	/**
	 * Construct a new Location instance according too another Location instance.
	 * @param location - other Location instance to construct from.
	 */
	public Location(Location location){
		x=location.x;
		y=location.y;
	}

	/**
	 * Comparator between locations.
	 */
	@Override
	public boolean equals(Object obj) {
		Location location = (Location)obj;
		return (this.x==location.x && this.y==location.y);
	}

	/**
	 * calculate the distance of current Location instance from another Instance.
	 * @param location - other Location to calculate distance from.
	 * @return the distance from the other location.
	 */
	public double distance(Location location){
		double xDistancePower2 = Math.pow((location.x-this.x), 2);
		double yDistancePower2 = Math.pow((location.y-this.y), 2);
		return Math.sqrt(xDistancePower2+yDistancePower2);
	}
}
